import axios from '@/libs/api.request'

export const getMenuList = ({menuname, level}) => {
  return axios.request({
    url: '/wh-portal/sys/menu/list',
    data: {
      menuName: menuname,
      level: level
    },

    method: 'post'
  })
};

export const getRoleMenuTree = ({menuName, roleId}) => {
  return axios.request({
    url: '/wh-portal/sys/menu/getMenuByRoleIds',
    data: {
      menuName: menuName,
      roleId: roleId,
    },

    method: 'post'
  })
};

export const getSysCodeList = () => {
  return axios.request({
    url: '/wh-portal/sys/menu/getSysCodeList',
    method: 'post'
  })
};


export const addMenuNode = (menuNode) => {
  return axios.request({
    url: '/wh-portal/sys/menu/add',
    params: {
      menuNode
    },
    method: 'post'
  })
};


export const updateNode = (menuNode) => {
  return axios.request({
    url: '/wh-portal/sys/menu/update',
    params: {
      menuNode
    },
    method: 'post'
  })
};

export const batchDeleteNodes = (ids) => {
  return axios.request({
    url: '/wh-portal/sys/menu/delete',
    params: {
      ids
    },
    method: 'post'
  })
};

export const updateMenuAuthByRoleId = ({menuIds, roleId}) => {
  return axios.request({
    url: '/wh-portal/sys/menu/updateMenuAuth',
    data: {
      menuIds: menuIds,
      roleId: roleId,
    },
    method: 'post'
  })
};
